////
/// Shared Utilities
/// Functions
////

// Column based max-width layout
// @param {Number} $count - Number of columns this element should span
@function columns($count: 1) {
  $column-count-max: 8;

  @if type-of($count) != number or $count < 1 or $count > $column-count-max {
    @error 'You did not provide a proper column count.';
  }

  $percentage: ($count / $column-count-max) * 100%;
  $gutter-width: ($count - 1) * get-layout-length(gutter);

  @return $percentage;
}

// Row based height layout
// @param {Number} $count - Number of rows this element should span
// @param {Boolean} $mobile - Use a smaller gutter if on mobile
// @param {Boolean} $inclusive - For use when the element is meant to begin within a gutter
@function rows($count: 1, $mobile: false, $inclusive: false) {
  @if type-of($count) != number or $count < 1 {
    @error 'You did not provide a proper row count.';
  }

  $gutter: if($mobile, get-layout-length(gutter, mobile), get-layout-length(gutter));
  $inclusive-gutters: if($inclusive, $gutter, 0);

  $row-height: $count * get-layout-length(row);
  $gutter-height: ($count - 1) * $gutter - $inclusive-gutters;

  @return $row-height + $gutter-height;
}
